﻿<%@ Page Title="" Language="C#" MasterPageFile="../Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    EzDesk - 考勤
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <%
        var dayInfo = ViewData["DayInfo"] as DayInfo;
        var isDisplayAttendanceInfo = (bool)ViewData["IsDisplayAttendanceInfo"];

        bool isDisplayEvaluationInfo = true;
        bool isDisplayApplyEvaluation = true;
        DayAttendnaceInfoDetailModel dayAttendanceDetail;
        IList<EvaluationModifyHistory> evaluationModifyHistory;
        if (isDisplayAttendanceInfo)
        {

        } %>
    <div id="PersonalAttendanceInfoPerDay">
        <%if (isDisplayAttendanceInfo)
          {%>
        <% isDisplayEvaluationInfo = (bool)ViewData["IsDisplayEvaluationInfo"];
           isDisplayApplyEvaluation = (bool)ViewData["IsDisplayApplyEvaluation"];
           dayAttendanceDetail = ViewData["DayAttendanceDetail"] as DayAttendnaceInfoDetailModel;
           evaluationModifyHistory = ViewData["EvaluationModifyHistory"] as IList<EvaluationModifyHistory>;
        %>
        <div class="sec">
            <h2>
                <%=dayInfo.Date.ToFullDate()%>
                考勤评估</h2>
        </div>
        <div class="sec">
            <div>
                <h3>
                    考勤记录:</h3>
                <%
                    foreach (var attendanceInfo in dayAttendanceDetail.AttendanceInfoList)
                    {%>
                <p>
                    <%=attendanceInfo.AttendanceType.GetAttendanceTypeString()%>
                    <b>:</b>
                    <%=attendanceInfo.ActionTime%>
                    <%} // end of foreach%>
                </p>
            </div>
        </div>
        <div class="sec">
            <div>
                <h3>
                    假期情况:</h3>
                <%
                    if (dayAttendanceDetail.LeaveInfo.Leaves != null)
                    {
                        foreach (var leave in dayAttendanceDetail.LeaveInfo.Leaves)
                        {
                %>
                <p>
                    <%=leave.LeaveTypeName%>
                    <b>:</b>
                    <%=leave.StartTime%>
                    至
                    <%=leave.EndTime%>
                </p>
                <%} // end of foreach %>
                <%} // end of if %>
            </div>
        </div>
        <%
            if (isDisplayEvaluationInfo)
            {%>
        <div class="sec">
            <div>
                <h3>
                    考勤评估:</h3>
                <p>
                    迟到<b> : </b>
                    <%= dayAttendanceDetail.AttendanceEvaluation.LateMiniutes%>
                    分钟</p>
                <p>
                    早退<b> : </b>
                    <%= dayAttendanceDetail.AttendanceEvaluation.EarlyMiniutes%>
                    分钟</p>
                <p>
                    旷工<b> : </b>
                    <%= dayAttendanceDetail.AttendanceEvaluation.IsAbsense.GetBoolString()%>
                </p>
                <p>
                    加班<b> : </b>
                    <%= dayAttendanceDetail.AttendanceEvaluation.IsExtraWork.GetBoolString()%>
                </p>
                <p>
                    工时<b> : </b>
                    <%= (dayAttendanceDetail.AttendanceEvaluation.Manhours)/10.00%>小时
                </p>
            </div>
        </div>
        <%} // end of if %>
        <%if (evaluationModifyHistory != null)
          {
        %><div class="sec">
            <%foreach (var modifyHistory in evaluationModifyHistory)
              {%>
            <h2>
                <%= modifyHistory.Operator.Name%>
                在
                <%= modifyHistory.ModifyOn%>
                修改过您的考勤评估。
            </h2>
            <%} // end of foreach %>
        </div>
        <%} // end of if %>
        <div class="sec">
            <%if (isDisplayApplyEvaluation)
              {%>
            <div class="sec">
                <form method="post" action="/Attendance/ApplyModifyAttendanceEvaluation">
                <%= Html.Hidden("date", dayInfo.Date.ToEpoch())%>
                <div class="sec">
                    <textarea name="applyText" rows="4"></textarea>
                </div>
                <input type="submit" class="button" value="申请修改" />
                </form>
            </div>
            <%} // end of if %>
            <%else
                {
            %>
            <h3 style="color: red;">
                *您暂时不能申请修改今天的考勤评估！</h3>
        </div>
        <%} // end of else %>
        <%} // end of if %>
        <%else
            {
        %><div class="sec">
            <h2>
                今天还没到呢！</h2>
        </div>
        <%} // end of else %>
    </div>
</asp:Content>
